---
- name: ensure packages required for libtaskotron are installed (yum)
  yum: name={{ item }} state=latest enablerepo={{ extra_enablerepos }}
  with_items:
    - PyYAML
    - libtaskotron
    - resultsdb_api
  when: deployment_type == 'prod' or deployment_type == 'local'

- name: ensure packages required for libtaskotron are installed (dnf)
  dnf: name={{ item }} state=latest enablerepo={{ extra_enablerepos }}
  when: deployment_type == 'dev' or deployment_type == 'stg'
  with_items:
    - PyYAML
    - libtaskotron
    - resultsdb_api

- name: ensure packages required for taskotron tasks are installed (yum)
  yum: name={{ item }} state=latest enablerepo={{ extra_enablerepos }}
  with_items:
    - python-solv
    - python-librepo
    - rpmlint
  when: ansible_distribution_major_version|int < 22

- name: ensure packages required for taskotron tasks are installed (dnf)
  dnf: name={{ item }} state=latest enablerepo={{ extra_enablerepos }}
  with_items:
    - python-solv
    - python-librepo
    - rpmlint
  when: ansible_distribution_major_version|int > 21 and ansible_cmdline.ostree is not defined

- name: generate taskotron.yaml config file
  template: src=taskotron.yaml.j2 dest=/etc/taskotron/taskotron.yaml owner=root group=root mode=0644

# hotfixing correct yumrepoinfo until libtaskotron is updated
- name: upload yumrepoinfo.conf
  copy: src=yumrepoinfo.conf dest=/etc/taskotron/yumrepoinfo.conf owner=root group=root mode=0644

- name: set baseurl of yumrepoinfo.conf
  replace: dest=/etc/taskotron/yumrepoinfo.conf regexp='baseurl = http://download\.fedoraproject\.org/.*' replace='baseurl = http://infrastructure.fedoraproject.org/pub/fedora/linux'

- name: create /var/log/taskotron for task logfiles
  file: path=/var/log/taskotron state=directory owner={{ slave_user }} group={{ slave_user }} mode=1755
  when: deployment_type == 'prod' or deployment_type == 'stg' or deployment_type == 'local'

- name: create /var/log/taskotron for task logfiles
  file: path=/var/log/taskotron state=directory owner=root group={{ slaves_group }} mode=1775
  when: deployment_type == 'dev'
